/*
 * $Id$
 */

package corejs.stmt;

import corejs.expr.Expression;
import corejs.expr.ExpressionVisitor;

/**
 *
 * @author pengyu
 */
public class For extends Loop {

   private final Expression _init;
   private final Expression _step;
  
   public For(final Expression init, final Expression test, 
              final Expression step, final Statement stmt) {
      super(test, stmt);
      _init = init;
      _step = step;
   }

   /**
    * 
    * @param v 
    */
   @Override
   protected void beforeLoop(final ExpressionVisitor v) {
      if (null != _init) _init.accept(v);
   }

   /**
    * 
    * @param v
    * @return 
    */
   @Override
   protected boolean afterEachIteration(final ExpressionVisitor v) {
      if (null != _step) _step.accept(v);
      return false;
   }
}
